package com.ruoyi.food.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.food.object.TActivity;

/**
 * 活动mapper
 * @author mengcc
 *
 */
@Mapper
public interface TActivityMapper extends BaseMapper<TActivity>{

	public static String sql="SELECT a.ACT_NAME,a.ACT_TYPE,a.START_TIME,a.END_TIME,a.IS_VALID,a.PRICE,a.VOUCHER,a.AMOUNT,o.ACT_ID,count(*)as num "
			+ "from t_activity a LEFT JOIN t_act_order o on a.ACT_ID=o.ACT_ID  GROUP BY a.ACT_ID";
	
	@Select({"<script>",
        sql,
        "having 1=1",
        "<when test='actName != \"\" and actName !=null'>",
        "AND a.ACT_NAME like concat('%', #{actName}, '%')",
        "</when>",
        "<when test='isValid != 3'>",
        "AND a.IS_VALID=#{isValid}",
        "</when>",
        "<when test='params.beginTime != \"\" and params.beginTime !=null'>",
        "AND date_format(a.START_TIME,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')",
        "</when>",
        "<when test='params.endTime != \"\" and params.endTime != null'>",
        "AND date_format(a.END_TIME,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')",
        "</when>",       
        "</script>"})
	public List<TActivity> selectTActivity(TActivity tActivity);

}
